/**
 * 
 */
package vwg.na.vwm.rh.modulo.managedbeans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import org.apache.log4j.Logger;

import vwg.na.vwm.rh.motorsdk.sesion.RHSesion;
import vwg.na.vwm.rh.rhmotor.modelo.entidad.Historial;
import vwg.na.vwm.rh.rhmotor.modelo.entidad.Historico;
import vwg.na.vwm.rh.rhmotor.modelo.servicio.HistoricoServicio;
import vwg.na.vwm.rh.rhmotor.util.RHConstantes;
@ManagedBean(name="historicoMB")
@ViewScoped
public class HistoricoMB implements Serializable {

	private static final long serialVersionUID = -8056966556466197993L;
	private static final Logger logger = Logger.getLogger(HistoricoMB.class.getName());
	
	@ManagedProperty(value = "#{historicoServicio}")
	private HistoricoServicio historicoServicio;
	
	private List<Historico> historicoList;
	private Historico historico;
	private List<Historial> listaHistorial;
	
	public HistoricoMB() {
		listaHistorial = new ArrayList<Historial>();
	}
	
	@PostConstruct
	public void init() {
		historicoList = new ArrayList<Historico>();
		Long registroId = (Long) RHSesion.getVariableSesion(RHConstantes.CORE_REGISTRO_ID_ACTUAL);
		if (registroId != null) {
			historicoList = historicoServicio.findByRegistroId(registroId);
			this.listaHistorial = Historial.getHistoricoToHistorial(historicoList);
		}
	}

	public List<Historico> getHistoricoList() {
		return historicoList;
	}

	public void setHistoricoList(List<Historico> historicoList) {
		this.historicoList = historicoList;
	}

	public Historico getHistorico() {
		return historico;
	}

	public void setHistorico(Historico historico) {
		this.historico = historico;
	}
	public HistoricoServicio getHistoricoServicio() {
		return historicoServicio;
	}
	public void setHistoricoServicio(HistoricoServicio historicoServicio) {
		this.historicoServicio = historicoServicio;
	}

	public List<Historial> getListaHistorial() {
		return listaHistorial;
	}

	public void setListaHistorial(List<Historial> listaHistorial) {
		this.listaHistorial = listaHistorial;
	}
}
